#include <iostream>
#include <memory>
#include "udpserver.hpp"

int main(int argc, char *argv[])
{
    // 1.判断输入参数
    if (argc != 3)
    {
        std::cout << "Usage " << argv[0] << " IP Port" << std::endl;
        exit(1);
    }
    // 2.解析参数
    char server_ip[17];
    memset((void *)server_ip, 0, sizeof(server_ip));
    memcpy((void *)server_ip, argv[1], strlen(argv[1]));
    uint16_t server_posr = std::stoi(argv[2]);

    // 3.创建参数
    //  用智能指针管理
    std::unique_ptr<Udp_Server::UdpServer> use_server = std::make_unique<Udp_Server::UdpServer>(server_ip, server_posr);
    std::cout << "对象创建成功" << std::endl;

    // 初始化
    use_server->Init();
    std::cout << "对象初始化成功" << std::endl;

    // 启动
    use_server->Start();

    return 0;
}